package math.base;

/**
 * @author Saga
 *
 */
public class Vector2d {
    public Vector2d() {
        this.coord = new Coord2d(0.0, 0.0);
    }

    public Vector2d(final double _x, final double _y) {
        this.coord = new Coord2d(_x, _y);
    }

    public Vector2d(final Coord2d _coord) {
        this.coord = _coord;
    }

    public Vector2d(final Dir2d _direct) {
        this.coord = _direct.getCoord();
    }

    public final void init(final double _x, final double _y) {
        this.coord.init(_x, _y);
    }

    public final void setCoord(final Coord2d _coord) {
        this.coord = _coord;
    }

    public final Coord2d getCoord() {
        return this.coord;
    }

    public final void setCoord(final int _id, final double _val) {
        this.coord.setCoord(_id, _val);
    }

    public final double getCoord(final int _id) {
        return this.coord.getCoord(_id);
    }

    public final void setX(final double _x) {
        this.coord.setX(_x);
    }

    public final double getX() {
        return this.getCoord().getX();
    }

    public final void setY(final double _y) {
        this.coord.setY(_y);
    }

    public final double getY() {
        return this.getCoord().getY();
    }

    //add
    public final void add(final Vector2d _vec) {
        this.coord.add(_vec.getCoord());
    }

    public final Vector2d added(final Vector2d _vec) {
        return new Vector2d(this.coord.added(_vec.getCoord()));
    }

    //subtract
    public final void subtract(final Vector2d _vec) {
        this.coord.subtract(_vec.getCoord());
    }

    public final Vector2d subtracted(final Vector2d _vec) {
        return new Vector2d(this.coord.subtracted(_vec.getCoord()));
    }

    //multiply
    public final void multiply(final double _scalar) {
        this.coord.multiply(_scalar);
    }

    public final Vector2d multiplied(final double _scalar) {
        return new Vector2d(this.coord.multiplied(_scalar));
    }

    //divide
    public final void divide(final double _denom) {
        this.coord.divide(_denom);
    }

    public final Vector2d divided(final double _denom) {
        return new Vector2d(this.coord.divided(_denom));
    }

    @Override
    public final Vector2d clone() {
        return new Vector2d(this.coord.clone());
    }

    private Coord2d coord;
}
